<%@ page contentType="text/html;charset=UTF-8" import="java.util.*,com.hanma.bean.User" language="java" %>
<%@ page import="com.hanma.bean.Comments" %>
<%@ page import="com.hanma.bean.Record" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>个人中心</title>
<link rel="stylesheet" href="/message/home/css/my.css">
<link href="/message/home/css/bootstrap.min.css" rel="stylesheet">
<link href="/message/home/css/main.css" rel="stylesheet">
<link rel="stylesheet" href="/message/home/font/iconfont.css">
<link rel="stylesheet" href="/message/home/font/iconfont.css">
<script src="/message/home/js/jquery.min.js"></script>
</head>
<%
    User user = (User) request.getAttribute("user");
    List<Comments> commentsList = (List<Comments>) request.getAttribute("commentsList");
    List<Record> recordList = (List<Record>) request.getAttribute("recordList");
%>
<body>
<div class="navbar navbar-default">
    <div class="container">
        <div class="navbar-header">
            <a href="#" class="navbar-brand"></a>
        </div>
        <label id="toggle-label" class="visible-xs-inline-block" for="toggle-checkbox">导航栏</label> <input class="hidden" id="toggle-checkbox" type="checkbox">
        <div class="hidden-xs">
            <ul class="navbar nav navbar-nav">
                <li>
                    <a href="/message/signIndex.do?cateId=0&uid=<%=user.getId()%>">首页</a>
                </li>
            </ul>
        </div>
    </div>
</div>
	  <div class="content">

        <div class="userInfo">
            <div class="userInfo_left">
                <img class="userInfo_icon" src="<%=user.getHead()%>" alt="" class="userInfo_icon">
                <div class="userInfo_nickname"><%=user.getNickname()%></div>
                <form action="/message/myHeadAction.do" enctype="multipart/form-data" method="post">
                <input type="file" name="head" class="choose_head">
                <input type="submit" value="修改" class="update_head">
                </form>
            </div>
            <div class="userInfo_right">
                <div class="userInfo_collect">
                    <div class="userInfo_collect_top">${commentsNum}</div>
                    <div class="userInfo_collect_bottom">评论</div>
                </div>
                <div class="userInfo_collect">
                    <div class="userInfo_collect_top">${recordNum}</div>
                    <div class="userInfo_collect_bottom">浏览足迹</div>
                </div>
            </div>
        </div>
        <div class="updateInfo">
            <div class="updateInfo_nav">
                <div class="updateInfo_nav_title active"><a href="my.do?id=<%=user.getId()%>&location=1">个人信息</a></div>
                <div class="updateInfo_nav_title"><a href="my.do?id=<%=user.getId()%>&location=2">我的评论</a></div>
                <div class="updateInfo_nav_title"><a href="my.do?id=<%=user.getId()%>&location=3">浏览足迹</a></div>
            </div>
            <%
                Integer location = (Integer)request.getAttribute("location");
                if(location == 1){
            %>
            <form action="/message/myAction.do" method="post">
            <div class="updateInfo_content">
                <div class="updateInfo_content_item">
                    <div class="updateInfo_content_item_left">我的昵称：</div>
                    <input class="updateInfo_content_item_right" type="text" name="nickname" value="<%=user.getNickname()==null ? "" : user.getNickname()%>"
                        placeholder="请输入用户昵称">
                </div>
                <div class="updateInfo_content_item">
                    <div class="updateInfo_content_item_left">手机号码：</div>
                    <input class="updateInfo_content_item_right" type="text" name="tel" value="<%=user.getTel()==null ? "" : user.getTel()%>"
                        placeholder="请输入手机号码">
                </div>
                <div class="updateInfo_content_item">
                    <div class="updateInfo_content_item_left">电子邮箱：</div>
                    <input class="updateInfo_content_item_right" type="email" name="email" value="<%=user.getEmail() == null ? "" : user.getEmail()%>"
                        placeholder="请输入电子邮箱">
                </div>
                <div class="updateInfo_content_item">
                    <div class="updateInfo_content_item_left">当前密码：</div>
                    <input class="updateInfo_content_item_right" type="password" name="password" value="<%=user.getPassword()%>"
                        placeholder="请输入密码" >
                </div>
                <div class="updateInfo_content_item">
                    <div class="updateInfo_content_item_left">密码重置：</div>
                    <input class="updateInfo_content_item_right" type="password" name="new_password" value="" placeholder="请输入新密码">
                </div>
                <button type="submit" class="updateInfo_content_item_left confirmUpdate">确认修改</button>
                <a type="button" href="/message//list.do" class="updateInfo_content_item_left confirmUpdate">退出登录</a>
            </div>
            </form>

            <%
                }else if(location == 2){
                    for(Comments comments : commentsList){
            %>
            <div class="comment_other">
                <div class="other_people">
                    <div class="other_prople_top">
                        <img class="other_prople_top_head" src="<%=comments.getImg()%>"  alt="">
                        <div class="other_prople_top_name"><%=comments.getNickname()%></div>
                    </div>
                    <div class="other_prople_bottom">
                        <div class="other_prople_bottom_content"><%=comments.getComment()%></div>
                        <div class="other_prople_bottom_time">
                            <div>来自双旦新闻网友</div>
                            <div>2023-9-5</div>
                        </div>
                    </div>
                </div>
            </div>
            <%
            }
            %>
            <%
                String currentPage = request.getAttribute("currentPage").toString();
                String totalPage = request.getAttribute("totalPage").toString();
                String prePage = request.getAttribute("prePage").toString();
                String nextPage = request.getAttribute("nextPage").toString();
            %>
            <ul class="pagination">
                <li class="disabled"><span>«</span></li>
                <li class="active">
                    <span>当前[<%= currentPage%>]页</span>
                </li>
                <li>
                    <span>共[<%= totalPage%>]页</span>
                </li>
                <li>
                    <span><a href="my.do?id=<%=user.getId()%>&location=2&currentPage=1">首页</a></span>
                </li>
                <li>
                    <span><a href="my.do?id=<%=user.getId()%>&location=2&currentPage=<%= prePage%>">上一页</a></span>
                    <span><a href="my.do?id=<%=user.getId()%>&location=2&currentPage=<%= nextPage%>">下一页</a></span>
                    <span><a href="my.do?id=<%=user.getId()%>&location=2&currentPage=<%= totalPage%>">尾页</a></span>
                </li>
            </ul>
            <%
                }else if(location == 3){
                for(Record record : recordList){
            %>
            <div class="comment_other">
                <div class="other_people">
<%--                    <div class="other_prople_top">--%>
<%--                        <img class="other_prople_top_head" src="/message/home/img/4.jpeg"  alt="">--%>
<%--                        <div class="other_prople_top_name"><%=comments.getNickname()%></div>--%>
<%--                    </div>--%>
                    <div class="other_prople_bottom">
                        <div class="other_prople_bottom_content"><a href="newsSign.do?nid=<%=record.getNid()%>"><%=record.getTitle()%></a></div>
                        <div class="other_prople_bottom_time">
<%--                            <div>来自双旦新闻网友</div>--%>
                            <div>2023-9-5</div>
                        </div>
                    </div>
                </div>
            </div>
            <%
            }
            %>
            <%
                String currentPage = request.getAttribute("currentPage").toString();
                String totalPage = request.getAttribute("totalPage").toString();
                String prePage = request.getAttribute("prePage").toString();
                String nextPage = request.getAttribute("nextPage").toString();
            %>
            <ul class="pagination">
                <li class="disabled"><span>«</span></li>
                <li class="active">
                    <span>当前[<%= currentPage%>]页</span>
                </li>
                <li>
                    <span>共[<%= totalPage%>]页</span>
                </li>
                <li>
                    <span><a href="my.do?id=<%=user.getId()%>&location=3&currentPage=1">首页</a></span>
                </li>
                <li>
                    <span><a href="my.do?id=<%=user.getId()%>&location=3&currentPage=<%= prePage%>">上一页</a></span>
                    <span><a href="my.do?id=<%=user.getId()%>&location=3&currentPage=<%= nextPage%>">下一页</a></span>
                    <span><a href="my.do?id=<%=user.getId()%>&location=3&currentPage=<%= totalPage%>">尾页</a></span>
                </li>
            </ul>
            <%
                }
            %>
        </div>
    </div>
<style>
    .choose_head{
        width: 100px;
    }
    .update_head{
        width: 50px;
    }
    .comment_other {
        width: 100%;
        display: flex;
        flex-direction: column;
        margin-top: 20px;
    }

    .other_people {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .other_prople_top {
        display: flex;
        align-items: center;
    }

    .other_prople_top_head {
        display: block;
        width: 60px;
        height: 60px;
        border-radius: 50%;
    }

    .other_prople_top_name {
        margin-left: 20px;
        cursor: pointer;
        color: rgb(155, 157, 14);
    }

    .other_prople_bottom {
        margin-left: 80px;
        display: flex;
        flex-direction: column;
    }

    .other_prople_bottom_content {
        font-size: 24px;
    }

    .other_prople_bottom_time {
        color: #999999;
        font-size: 16px;
        display: flex;
        align-items: center;
        margin-top: 10px;
    }

    .other_prople_bottom_time div:nth-child(2) {
        margin-left: 20px;
    }
</style>
</body>
</html>
